package com.chenfan.mcn.service.impl;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.chenfan.mcn.model.dto.SettlementCommodityInputDTO;
import com.chenfan.mcn.model.vo.LiveCommodityMatchResultVO;
import com.chenfan.mcn.utils.CommonUtil;
import lombok.Data;

import java.util.Map;
import java.util.Objects;

/**
 * @author: WQ
 * Date 2023/3/30
 * @描述
 */
@Data
public class SettlementCommodityOutputDTO extends SettlementCommodityInputDTO {

    private static final long serialVersionUID = -1857897617104909327L;

    /**
     * 失败原因
     */
    @Excel(name = "失败原因" , orderNum = "100")
    private String failedReason;

    /**
     * 匹配结果VO
     */
    private LiveCommodityMatchResultVO matchResultVO;

    /**
     * 校验系统数据匹配
     * @param anchorMap
     * @param separator
     */
    public void verifySysDataMatch(Map<String, Long> anchorMap, String separator) {
        if(!anchorMap.containsKey(this.getAnchorName())) {
            this.setFailedReason(CommonUtil.joinWith(separator,this.getFailedReason(), "主播档案找不到，请检查红人列表基础档案！"));
        }
    }

    public Long getLccId() {
        return Objects.nonNull(matchResultVO) ? matchResultVO.getLccId() : null;
    }
}
